package com.ymatou.iapi.fastturnover.testcase;

import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.fastturnover.parameter.addBean;
import com.ymatou.iapi.fastturnover.parameter.closeBean;
import com.ymatou.iapi.fastturnover.service.addCall;
import com.ymatou.iapi.fastturnover.service.closeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.FastTurnoverService;
import com.ymttest.database.model.fastturnover.account_config_log;
import com.ymttest.database.model.fastturnover.account_config_logExample;
import com.ymttest.database.sqlwapper.fastturnover.account_config_logWrapper;
import com.ymttest.utils.EnvSetup;
/**
*关闭配置
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_close{
	private static closeBean bean;
	private static closeCall call;
	
	Long fastturnover_seller=Long.parseLong(EnvSetup.getData("fastturnover_seller"));
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("关闭配置");
	}

	@Before
	public void caseUp() {
		bean=new closeBean();
		call=new closeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_close_001() {
		Logger.start(true,"关闭配置");
		try {
			addBean addBean=FastTurnoverService.initAdd(fastturnover_seller);
			addCall addCall=FastTurnoverService.AddCall(addBean);
			
			bean.setSellerId(addBean.getSellerId());
			bean.setOperator(addBean.getOperator());
			call.setData(bean);
			call.callService();			
			
			account_config_logExample example=new account_config_logExample();
			example.createCriteria().andSeller_idEqualTo(bean.getSellerId());
			example.setOrderByClause(" id desc");
			
			account_config_logWrapper logWapper=new account_config_logWrapper();
			account_config_log log=logWapper.selectByExample(example).get(0);
			
			Logger.verifyEquals("200", call.getCode1(), "验证code");
			Logger.verifyEquals("true", call.getResult(), "验证result");
			Logger.verifyEquals(log.getAction_type(), 3, "验证action_type 1，新增，2修改，3关闭");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}